<?php $this->load->view('templates/backend/header'); ?>
<h3><?php echo $this->lang->line("transportTicket");?></h3>
<style>
    .fone_num_cls{
        width:15%;  vertical-align: top;
    }
    .navbar-inverse{
        display: none;
    }
    body{
        padding-top:10px;
        padding-bottom:30px;
    }
</style>

<div class="well">
    <?php echo form_open();?>
        <div class="tab-content">	
            <div class="tab-pane active" id="main">
                <?php
                     //mã KH
                echo form_label($this->lang->line('customerID'), 'customerID');
                echo form_input(array('name' => 'customerID', 'id' => 'customerID', 'value' => ($transportTicket->customerID)?$transportTicket->customerID:'','readonly' => 'true'));
                echo form_error('customerID');
                
                    //danh sach tinh thanh
                echo form_label($this->lang->line('province'), 'province');
                echo form_dropdown('province', $this->paymentAtHome_model->getListProvince(), ($transportTicket->province)?$transportTicket->province:'','id="province"');
                echo form_error('province');
                
                   //danh sach quan / huyen
                echo form_label($this->lang->line('district'), 'district');
                echo form_dropdown('district', $this->paymentAtHome_model->getListDistrict($transportTicket->province), ($transportTicket->district)?$transportTicket->district:'','id="district"');
                echo form_error('district');
                
                   //danh sach nhan vien giao vé
                echo form_label($this->lang->line('ticketWorkers'), 'ticketWorkers');
                echo form_dropdown('ticketWorkers',$this->paymentAtHome_model->getListTicketWorkers(),($transportTicket->ticketWorkers)?$transportTicket->ticketWorkers:'','id="ticketWorkers"');
                echo form_error('ticketWorkers');
                
                //hidden
                echo form_input(array('type'=>'hidden', 'name' => 'id', 'value' => $transportTicket->id));
                echo form_input(array('type'=>'hidden', 'name' => 'booking_id', 'value' => $transportTicket->booking_id));
                ?>
            </div>
        </div>
        <div class="top-button">
                <?php echo form_button(array('id' => 'submit', 'value' => 'Update', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('save'),'class' => 'btn btn-primary')); ?>
                <?php echo form_button(array('id' => 'cancel','content' => $this->lang->line('close'),'class' => 'btn btn-danger')); ?>
        </div>
    <?php form_close();?>
    <span id="simple-msg-submit"></span>
</div>

<?php $this->load->view('templates/backend/footer'); ?>
<script>
$(document).ready(function() {
   $("#province").on('change',function(e){
            setTimeout(function () {
                $.ajax(
                    {
                        url : '/auth/geological/getDistrictByProvince/',
                        type: "POST",
                        data : {province : $("#province").val()},
                        cache: true,
                        beforeSend: function(){
                            
                        },
                        success:function(data) 
                        {
                            if(data){
                                var json = JSON.parse(data);
                                emptySelectBoxById('district',json);
                                delete json;
                            } else {
                                document.getElementById('district').innerHTML = "<option value=''>Không tìm thấy thông tin</option>";
                            }
                        },
                        error: function() 
                        {
                            alert("Lỗi! Contact Admin!");
                        }
                    });
            }, 222);
            e.preventDefault();	//STOP default action
   });
   
   $("#cancel").on('click',function(){
      parent.jQuery.fancybox.close(); 
   });
   
   $('form').submit(function(e) {
            $("#simple-msg-submit").html("Vui lòng chờ... <img src='<?php echo base_url().'static/templates/frontend/home/images/';?>loading.gif'/> ");
            $(this).find("button[type='submit']").prop('disabled',true);
    });
});

function emptySelectBoxById(eid, value) {
    if(value){
        var text = "";
        $.each(value, function(k, v) {
                //display the key and value pair
                if(k != ""){
                    text += "<option value='" + k + "'>" + v + "</option>";
                }
        });
        document.getElementById(eid).innerHTML = text;
        delete text;
    }
}
</script>
    
    
    